package cn.cvs.dao;

import cn.cvs.utils.ConfigManager;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

public class BaseDao {
    /**
     * 获取数据库连接对象
     */
    public static Connection getConnection(){
        Connection connection = null;
        String driver = ConfigManager.getInstance().getValue("driver");
        String url = ConfigManager.getInstance().getValue("url");
        String user = ConfigManager.getInstance().getValue("user");
        String password = ConfigManager.getInstance().getValue("password");
        try {
            Class.forName(driver);
            connection = DriverManager.getConnection(url,user,password);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return connection;
    }
}
